package com.fyzk.activity.fragment;

import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView.LayoutParams;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.alibaba.fastjson.JSON;
import com.fyzk.activity.app.AppToast;
import com.fyzk.activity.lottery.shuzicai.InfoDetailActivity;
import com.fyzk.activity.lottery.togetherbuy.HeMaiGenDanActivity;
import com.fyzk.activity.user.NetProgressView;
import com.fyzk.adapter.togetherbuy.TogetherbuyListAdapter;
import com.fyzk.base.BaseFragment;
import com.fyzk.bean.togetherbuy.TogetherHallItem;
import com.fyzk.data.AppLotteryInfos;
import com.fyzk.dialog.TogetherFilterPop;
import com.fyzk.interfaces.onTopTitleClickListener;
import com.fyzk.net.Commands;
import com.fyzk.utils.HelpUrlConstants;
import com.fyzk.utils.IntentParamUtils;
import com.fyzk.view.TopTitleView;
import com.marshalchen.ultimaterecyclerview.UltimateRecyclerView;
import com.marshalchen.ultimaterecyclerview.layoutmanagers.ScrollSmoothLineaerLayoutManager;
import com.tyjc.lottery.R;

import org.json.JSONException;
import org.json.JSONObject;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.ArrayList;
import java.util.List;

import http.Common.CommandUtil;
import http.StringResultBean;

/**
 * 合买大厅
 */
@ContentView(R.layout.fragment_togetherbuy_hall)
public class TogetherBuyHallFragment extends BaseFragment {
    @ViewInject(R.id.gold_documentary_tb)
    TabLayout mGoldDocumentaryTab;
    @ViewInject(R.id.documentary_vp_gold)
    ViewPager mDocumentaryVpGold;
    private TogetherBuyHallAdapter mAdapter;

    private List<Fragment> mFragment = new ArrayList<>();

    public static TogetherBuyHallFragment newInstance() {
        TogetherBuyHallFragment fragment = new TogetherBuyHallFragment();
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return x.view().inject(this, inflater, container);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initViews();
    }

    private void initViews() {
        mFragment.add(TogetherBuyHallChildFragment.newInstance(1));
        mFragment.add(TogetherBuyHallChildFragment.newInstance(3));
        mAdapter = new TogetherBuyHallAdapter(getChildFragmentManager());
        mDocumentaryVpGold.setAdapter(mAdapter);
        mGoldDocumentaryTab.setupWithViewPager(mDocumentaryVpGold);
    }

    private class TogetherBuyHallAdapter extends FragmentStatePagerAdapter {
        private String[] mTitle = new String[]{"进度排序", "彩金排序"};

        public TogetherBuyHallAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int i) {
            return mFragment.get(i);
        }

        @Override
        public int getCount() {
            return mFragment.size();
        }

        @Nullable
        @Override
        public CharSequence getPageTitle(int position) {
            return mTitle[position];
        }
    }

}
